<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>

        div {
            width: 100px;
            height: 100px;
            position: relative;
            background-color: pink;
        }

    </style>
</head>
<body>

<button id="btn">动画</button>

<div id="box">

</div>


<script>
    var btn = document.getElementById("btn");
    var box = document.getElementById("box");
    var timer = null;

    btn.onclick = function () {
        timer = setInterval(function () {

            box.style.left = box.offsetLeft + 5 + "px";
            if(box.offsetLeft >= 400){
                clearInterval(timer);
            }

        },30);
    }

    //缓动动画
</script>
</body>
</html>